﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ParsingUrl
{
    class UrlParser
    {
        static void Main(string[] args)
        {
            string text = "http://www.devbg.org/forum/index.php";
            string pattern = @"(?<protocol>\w+)://(?<server>[\.\w]*)/(?<resourse>[\./\w]*)";

            Regex expression = new Regex(pattern, RegexOptions.IgnoreCase);
            Match matcher = expression.Match(text);
            while (matcher.Success) 
            {
                Group protocol = matcher.Groups["protocol"];
                Group server = matcher.Groups["server"];
                Group resourse = matcher.Groups["resourse"];

                Console.WriteLine("{0}->protocol\n{1}->server\n{2}->resourse\n",protocol, server, resourse);
                matcher = matcher.NextMatch();
            }
        }
    }
}
